package ar.com.solidussource.howmuchmobile.activities;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import ar.com.solidussource.howmuchmobile.R;
import ar.com.solidussource.howmuchmobile.activities.filter.CurrentFilter;
import ar.com.solidussource.howmuchmobile.activities.generic.BaseActivity;

/**
 * Created with IntelliJ IDEA.
 * User: FT31270775
 * Date: 23/11/12
 * Time: 15:30
 * To change this template use File | Settings | File Templates.
 */
public class ProductCreateActivity extends BaseActivity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = (View) inflater.inflate(R.layout.create_product, null);

        Button category = (Button) v.findViewById(R.id.category);

        category.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ProductCreateActivity.this, ProductCategoryListOnCreateProductActivity.class);
                //intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                startActivity(intent);
            }
        });

        Button subcategory = (Button) v.findViewById(R.id.subcategory);

        subcategory.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if(CurrentFilter.getProductcategory() != null) {
                    Intent intent = new Intent(ProductCreateActivity.this, ProductSubCategoryListOnCreateProductActivity.class);
                    //intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    startActivity(intent);
                }
                else {
                    Toast toast1 = Toast.makeText(getApplicationContext(), "Selecionar una Categoria!", Toast.LENGTH_SHORT);
                    toast1.show();
                }

            }
        });

        setContent(v);
    }
}